# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>

pkgbase=snowball
pkgname=(snowball libstemmer)
pkgver=2.1.0
pkgrel=1
pkgdesc="String processing language for creating stemming algorithms"
url="https://snowballstem.org/"
arch=(x86_64)
license=(BSD)
depends=(glibc)
makedepends=(git)
_commit=4764395431c8f2a0b4fe18b816ab1fc966a45837  # tags/v2.1.0^0
source=("git+https://github.com/snowballstem/snowball#commit=$_commit"
        dynamiclib.patch)
sha256sums=('SKIP'
            'fb8069aa4d1b5194fb8be231f87269f7a8fefdb3de0c20e2f0537fb4c9260328')

pkgver() {
  cd $pkgbase
  git describe --tags | sed 's/^v//;s/-/+/g'
}

prepare() {
  cd $pkgbase
  git apply -3 ../dynamiclib.patch
}

build() {
  cd $pkgbase
  make
}

check() {
  cd $pkgbase

  # Disabled - needs external test data
  #make check
}

package_snowball() {
  cd $pkgbase

  install -Dt "$pkgdir/usr/bin" snowball stemwords

  install -Dt "$pkgdir/usr/share/licenses/$pkgname" -m644 COPYING
}

package_libstemmer() {
  pkgdesc="Stemming library supporting several languages"
  provides=(libstemmer.so)

  cd $pkgbase

  install -Dt "$pkgdir/usr/lib" libstemmer.so.0.0.0
  ln -s libstemmer.so.0.0.0 "$pkgdir/usr/lib/libstemmer.so.0"
  ln -s libstemmer.so.0 "$pkgdir/usr/lib/libstemmer.so"

  install -Dt "$pkgdir/usr/include" -m644 include/libstemmer.h

  install -Dt "$pkgdir/usr/share/licenses/$pkgname" -m644 COPYING
}
